package org.rsbot.loader.script;

public class Buffer
{
  private int pos;
  private byte[] data;

  public Buffer(byte[] paramArrayOfByte)
  {
    this.data = paramArrayOfByte;
    this.pos = 0;
  }

  public int g1() {
    return this.data[(this.pos++)] & 0xFF;
  }

  public int g2() {
    this.pos += 2;
    return ((this.data[(this.pos - 2)] & 0xFF) << 8) + (this.data[(this.pos - 1)] & 0xFF);
  }

  public int g4() {
    this.pos += 4;
    return ((this.data[(this.pos - 4)] & 0xFF) << 24) + ((this.data[(this.pos - 3)] & 0xFF) << 16) + ((this.data[(this.pos - 2)] & 0xFF) << 8) + (this.data[(this.pos - 1)] & 0xFF);
  }

  public long g8() {
    long l1 = g4() & 0xFFFFFFFF;
    long l2 = g4() & 0xFFFFFFFF;
    return (l1 << 32) + l2;
  }

  public String gstr() {
    int i = this.pos;
    while (this.data[(this.pos++)] != 10);
    return new String(this.data, i, this.pos - i - 1);
  }

  public byte[] gstrbyte() {
    int i = this.pos;
    while (this.data[(this.pos++)] != 10);
    byte[] arrayOfByte = new byte[this.pos - i - 1];
    System.arraycopy(this.data, i, arrayOfByte, i - i, this.pos - 1 - i);
    return arrayOfByte;
  }

  public void gdata(byte[] paramArrayOfByte, int paramInt1, int paramInt2) {
    for (int i = paramInt2; i < paramInt2 + paramInt1; i++)
      paramArrayOfByte[i] = this.data[(this.pos++)];
  }
}